part of '../page.dart';

class _AllPhrasalVerbPageTheme extends InheritedTheme {
  _AllPhrasalVerbPageTheme({
    required Brightness brightness,
    required super.child,
  })  : _brightness = brightness,
        _data = _buildThemeData(
          brightness: brightness,
        );

  final Brightness _brightness;
  final _AllPhrasalVerbPageThemeData _data;

  static _AllPhrasalVerbPageThemeData _buildThemeData({
    required Brightness brightness,
  }) {
    return switch (brightness) {
      _ => _AllPhrasalVerbPageThemeData.dark(),
    };
  }

  static _AllPhrasalVerbPageThemeData of(BuildContext context) {
    final inheritedTheme = context.dependOnInheritedWidgetOfExactType<_AllPhrasalVerbPageTheme>()!;
    return inheritedTheme._data;
  }

  @override
  Widget wrap(BuildContext context, Widget child) {
    final ancestorTheme = context.findAncestorWidgetOfExactType<_AllPhrasalVerbPageTheme>();

    if (identical(this, ancestorTheme)) {
      return child;
    }

    return _AllPhrasalVerbPageTheme(
      brightness: _brightness,
      child: child,
    );
  }

  @override
  bool updateShouldNotify(_AllPhrasalVerbPageTheme oldWidget) {
    return _brightness != oldWidget._brightness;
  }
}

class _AllPhrasalVerbPageThemeData {
  const _AllPhrasalVerbPageThemeData._internal({
    required this.tableHeaderBackgroundColor,
    required this.tableHeaderDividerColor,
    required this.evenTableRowBackgroundColor,
    required this.oddTableRowBackgroundColor,
    required this.textTheme,
  });

  factory _AllPhrasalVerbPageThemeData.dark() {
    return _AllPhrasalVerbPageThemeData._internal(
      tableHeaderBackgroundColor: CoreStyles.darkGrey5,
      tableHeaderDividerColor: Colors.black,
      evenTableRowBackgroundColor: CoreStyles.darkGrey3,
      oddTableRowBackgroundColor: CoreStyles.darkGrey5,
      textTheme: _AllPhrasalVerbPageTextTheme.dark(),
    );
  }

  final Color tableHeaderBackgroundColor;
  final Color tableHeaderDividerColor;
  final Color evenTableRowBackgroundColor;
  final Color oddTableRowBackgroundColor;
  final _AllPhrasalVerbPageTextTheme textTheme;
}
